// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
#pragma once
#include "FileReaderWriter.h"

namespace Weathr
{
    // Helper class for loading and saving persitent location data.
    class LocationData
    {
    public:
        LocationData(LocationData const&) = delete;
        LocationData const& operator=(LocationData const&) = delete;

        // Gets the current instance.
        // Not thread safe.
        static LocationData& Current();

        // Reads the collection pre-defined app locations from disk.
        concurrency::task<web::json::value> LoadAppLocationsAsync();

        // Reads the collection user-defined locations from disk.
        concurrency::task<web::json::value> LoadUserLocationsAsync();

        // Writes the collection of user-defined locations to disk.
        concurrency::task<void> SaveUserLocationsAsync();

    private:
        LocationData();
        FileReaderWriter m_appLocationsFileReaderWriter;    // reader/writer for built-in locations
        FileReaderWriter m_userLocationsFileReaderWriter;   // reader/writer for user-defined locations
    };
}
